#ifndef N1FILE_H_2009_10_21
#define N1FILE_H_2009_10_21

#include "N1Object.h"

#ifdef WINDOWS
typedef wchar_t N1PathChar;
#else
typedef char N1PathChar; 
#endif


class N1AbstractFile : public N1Object {
public:
    virtual uint64 getSize() const =0;
    virtual uint64 getPosition() const =0;
    virtual uint64 setPosition(uint64 newPos)=0;

    virtual uint64 read(void* buffer, uint64 size)=0;
    virtual uint64 write(const void* buffer, uint64 size)=0;
};

class N1File : public N1AbstractFile {
public:
    N1NAME_DECL

    N1File();
    virtual ~N1File();

    bool create(const N1PathChar* name);
    bool openForRead(const N1PathChar* name);

    void close();

    virtual uint64 getSize() const ;
    virtual uint64 getPosition() const ;
    virtual uint64 setPosition(uint64 newPos);

    virtual uint64 read(void* buffer, uint64 size);
    virtual uint64 write(const void* buffer, uint64 size);

protected:
#ifdef WINDOWS
    HANDLE m_file;
#else
    FILE*  m_file;
#endif
};

#endif //N1FILE_H_2009_10_21
